package cn.enjoyedu.udp.broadcastLearn.acceptside;



import cn.enjoyedu.udp.broadcast.LogMsg;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class LogEventHandler extends SimpleChannelInboundHandler<LogMsg> {


    @Override
    protected void channelRead0(ChannelHandlerContext ctx, LogMsg event) throws Exception {
        //创建 StringBuilder，并且构建输出的字符串
        StringBuilder builder = new StringBuilder();
        builder.append(event.getTime());
        builder.append(" [");
        builder.append(event.getSource().toString());
        builder.append("] ：[");
        builder.append(event.getMsgId());
        builder.append("] ：");
        builder.append(event.getMsg());
        //打印 LogMsg 的数据
        System.out.println(builder.toString());
    }
}
